import LocalData from "./LocalData"
let isAuthenticated = false;
export default {
  methods: {
    GetIsAuthenticated() {
      return isAuthenticated;
    },

    async checkData(checkName: string, checkPass: string) {
      let promise = LocalData.methods.obtainData("administrators");
      let administratorsData = await promise;
      if (administratorsData == undefined) {
          isAuthenticated = false;
        return false;
      }
      let entry = administratorsData.find((item) => {
        return item.userName === checkName;
      });

      if (entry != undefined) {
        if (entry.password === checkPass) {
          isAuthenticated = true;
          return true;
        }
      }
      isAuthenticated = false;
      return false;
    },
  },
};